import type { Ref } from "vue";

export const userChatListStore = defineStore('userChatList', () => {
  const chatList:Ref<chatListItemType[]> = ref([]);
  function setUserChatList(chatListTemp:chatListItemType[]) {
    chatList.value = chatListTemp;
  }
  return { chatList, setUserChatList };
});

export const userJoinListStore = defineStore('userJoinList', () => {
  const joinList:Ref<joinListItemType[]> = ref([]);
  const friendList:Ref<joinListItemType[]> = ref([]);
  const groupList:Ref<joinListItemType[]> = ref([]);
  watch(joinList, () => {
    friendList.value = joinList.value.filter(item => item._type === 0);
    groupList.value = joinList.value.filter(item => item._type === 1);
  })
  function setUserJoinList(friendListTemp:joinListItemType[]) {
    joinList.value = friendListTemp;
  }
  
  return { joinList, setUserJoinList, friendList, groupList };
});
